<!--

    This file is part of kanji-portal.com.

    kanji-portal.com is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    kanji-portal.com is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with kanji-portal.com.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (c) 2008-2009 Nicolas Radde <nicolas@radde.org>

-->
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:a="http://richfaces.org/a4j"
                template="#{theme.template}">

    <!-- content -->
    <ui:define name="content">

        <div class="section">

            <fieldset>
                <legend>#{messages['kanji.search.text.search']}</legend>

                <h:form id="searchCriteria">
                    <h:inputText id="searchString" value="#{kanjiSearch.searchString}" style="width: 165px;">
                        <a:support event="onkeyup" actionListener="#{kanjiSearch.find}"
                                   reRender="searchResults, messages"/>
                    </h:inputText>
                    <a:commandButton id="findKanjis" value="#{messages['kanji.search.acb.findKanjis']}"
                                     action="#{kanjiSearch.find}"
                                     reRender="searchResults, messages"/>
                    <a:status>
                        <f:facet name="start">
                            <h:graphicImage value="#{theme.spinner}"/>
                        </f:facet>
                    </a:status>
                    <a:outputPanel id="messages">
                        <h:messages/>
                    </a:outputPanel>
                    <br/>
                    <s:div id="advancedSearch" rendered="false">
                        <h:outputLabel for="pageSize">#{messages['kanji.search.hol.pageSize']}</h:outputLabel>
                        <h:selectOneMenu value="#{kanjiSearch.pageSize}" id="pageSize">
                            <f:selectItem itemLabel="5" itemValue="5"/>
                            <f:selectItem itemLabel="10" itemValue="10"/>
                            <f:selectItem itemLabel="20" itemValue="20"/>
                        </h:selectOneMenu>
                    </s:div>
                </h:form>
            </fieldset>
        </div>
        <br/>
        <h:form id="kanjis">
            <a:outputPanel id="searchResults">
                <div class="section">
                    <h:outputText value="#{messages['kanji.search.hot.nokanjis']}"
                                  rendered="#{kanjis != null and kanjis.rowCount==0}"/>
                    <h:dataTable id="kanjis" value="#{kanjis}" var="kan" rendered="#{kanjis.rowCount>0}">
                        <h:column>
                            <f:facet name="header">#{messages['kanji.search.hdt.kanjis.header.kanji']}</f:facet>
                            <s:link view="/kanji/view.seam" propagation="none" value="#{kan.kanji}">
                                <f:param name="dataModelSelection"/>
                                <f:param name="kanjiId" value="#{kan.id}"/>
                            </s:link>
                        </h:column>
                        <h:column>
                            <f:facet name="header">#{messages['kanji.search.hdt.kanjis.header.meaning']}</f:facet>
                            #{searchMeanings.get(kan.id)}
                        </h:column>
                    </h:dataTable>
                    <br/>
                    <a:commandLink value="#{messages['kanji.search.acl.nextPage']}" action="#{kanjiSearch.nextPage}"
                                   rendered="#{kanjiSearch.nextPageAvailable}" reRender="searchResults"/>
                </div>
            </a:outputPanel>
        </h:form>

    </ui:define>

</ui:composition>
